👀 Reading hidden code
1000000👀 Reading hidden code
n = 1000_000
-0.332428
-0.340844
1.35112
-0.254767
0.595109
-0.630615
0.304435
0.408957
-0.462856
0.661398
-0.390741
0.173633
-0.937839
0.383105
-0.0518628
0.373071
-0.237987
0.353496
0.0843557
0.213686
0.937593
0.133086
-0.235871
-1.39479
0.418814
0.830796
-0.409324
0.792698
0.228096
0.0702236
👀 Reading hidden code
0.385195
0.43676
-0.262272
-0.278712
-0.0706725
-0.132227
0.583439
0.172482
-0.315643
-0.045073
0.615323
-0.192859
-0.187651
-0.575512
-1.43144
-0.353237
0.185968
-0.310977
0.00255574
0.715752
0.520835
-0.635905
-0.0881304
-0.773227
0.415887
0.250114
0.389844
-0.145941
-0.376563
-0.646682
👀 Reading hidden code
scatter(x,y; marker_size=ms)
👀 Reading hidden code
Deprecated, use `AbstractPlutoDingetjes.Display.published_to_js(x)` instead of `PlutoRunner.publish_to_js(x)`.
Deprecated, use `AbstractPlutoDingetjes.Display.published_to_js(x)` instead of `PlutoRunner.publish_to_js(x)`.
using PlutoUI
👀 Reading hidden code
👀 Reading hidden code
Definition
👀 Reading hidden code
using HypertextLiteral
👀 Reading hidden code
scatter (generic function with 1 method)scatter(x,y; kwargs...) = FastScatter(;x, y, kwargs...)
👀 Reading hidden code
👀 Reading hidden code
begin
Base.@kwdef struct FastScatter
x::Vector{<:Real}
y::Vector{<:Real}
color::String="#000000"
marker_size::Real=5
end
function Base.show(io::IO, m::MIME"text/html", f::FastScatter)
show(io, m, @htl("""
<div>
<canvas style="width: 100%; aspect-ratio: 1; border-radius: .6em;"></canvas>
<script>
const {default: createScatterplot} = await import('https://esm.sh/regl-scatterplot@1.2.3');
const canvas = currentScript.parentElement.querySelector("canvas")
const { width, height } = canvas.getBoundingClientRect();
const scatterplot = createScatterplot({
canvas,
width,
height,
pointSize: $(f.marker_size),
pointColor: [$(f.color)],
performanceMode: true,
});
const raw_x = $(Main.PlutoRunner.publish_to_js(convert(Vector{Float32}, f.x)))
const raw_y = $(Main.PlutoRunner.publish_to_js(convert(Vector{Float32}, f.y)))
const points = Array.prototype.map.call(raw_x, (x,i) => [x,raw_y[i]])
console.log(points.length, [...points[0]])
// const points = new Array(10000)
// .fill()
// .map(() => [-1 + Math.random() * 2, -1 + Math.random() * 2, 0]);
scatterplot.draw(points);
invalidation.then(() => {
// clear memory
points.length = 0
scatterplot.clear()
scatterplot.destroy()
})
</script>
</div>
"""))
end
end
👀 Reading hidden code
# begin
# Base.@kwdef struct FastScatter
# x
# y
# end
# function Base.show(io::IO, m::MIME"text/html", f::FastScatter)
# show(io, m, @htl("""
# <div>
# <canvas style="width: 100%; height: 300px"></canvas>
# <script>
# const {default: createScatterplot} = await import('https://esm.sh/regl-scatterplot@1.2.3');
# const raw_x = $(Main.PlutoRunner.publish_to_js(convert(Vector{Float32}, f.x)))
# const raw_y = $(Main.PlutoRunner.publish_to_js(convert(Vector{Float32}, f.y)))
# const points = Array.prototype.map.call(raw_x, (x,i) => [x,raw_y[i],0])
# console.log(points.length)
# </script>
# </div>
# """))
# end
# end
👀 Reading hidden code